import function,shutil,os
from PIL import Image

def pic_operate(path):
    img=Image.open(path)
    width, height = img.size
    if(width>1200):
        new_width=1200
        new_height=int(height*new_width/width)
    else:
        new_width=width
        new_height=height    
    name=os.path.basename(path)
    path_new="D:/Desk/系统图库/烫画集/1-待处理/缩小/"+name
    try:
        img=img.resize((new_width,new_height))
        img.save(path_new)
        print(name,'成功了喔')
    except:
        print(name,'失败了喔')    
    

paths=function.get_file_paths("D:/Desk/系统图库/烫画集/1-待处理/图案/")

i=0
for path in paths:
    # if i>2:
    #     break
    pic_operate(path)
    i+=1